<!--suppress ALL -->
<script src="/static/js/amazeui.datatables.min.js"></script>
<script src="/static/js/dataTables.responsive.min.js"></script>
<script src="/static/js/amazeui.page.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script src="/static/css/css/plugins/radialindicator.js"></script>
<!--<script src="/static/js/app.js"></script>-->
<!--<script src="/static/js/echarts.min.js"></script>-->
<script>
    var limit = {{.limit}};
    if ({{.total}} =='1')
    {
        sendajaxdata(limit, 0);
    }
    function sendajaxdata(limit, offset) {
        var progress = $.AMUI.progress;
        progress.start();
        offset = limit * (offset - 1 );

        var html = [];
        $.get("/sdvjson?limit=" + limit + "&offset=" + offset, function (data) {
            console.log('getjson');
            for (var i = 0; i < data.length; i++) {
                console.log(data)
                if(i % 2 === 0){
                    html += '<tr class="gradeX">';
                } else {
                    html += '<tr class="even gradeC">';
                }
                html += '<td>'+ (i + 1) +'</td>';
                html += '<td>' + data[i].CreateDate + '</td>';
                html += '<td>' + data[i].DeviceId + '</td>';
                html += '<td>' + data[i].DeviceType + '</td>';
                html += '<td>' + data[i].DeviceTroubleType + '</td>';
                html += '<td>' + data[i].DeviceTroubleDetails+ '</td>';
                html += '<td>' + data[i].Police+ '</td>';
                html += '<td>' + data[i].Dept+ '</td>';
                html += '<td>' + data[i].Unit+ '</td>';
                html += '<td>' + data[i].Comment+ '</td>';
                html += '<td><div class="indicatorContainer" ></div></td>';
                html += '<td>';
                html += '<div class="tpl-table-black-operation">';
                html += '<a href="javascript:editorDevice('+ data[i].Id +');">';
                html += '<i class="am-icon-pencil"></i> 编辑 </a>';
                html += '<a href="javascript:deleteDevice(' + data[i].Id + ');" class="tpl-table-black-operation-del">';
                html += '<i class="am-icon-trash"></i> 删除';
                html += '</a>';
                html += '</div>';
                html += '</td>';
                html += '</tr>';
            }
            $('#sdvlist').html(html);
            progress.done();
        });
    }

    showPage({{.total}});

    function deleteDevice(id) {
        $.ajax({
            type : "GET",
            url : "/sdvjson/delete?Id=" + id,
            success : function(data){
                console.log(data);
                window.location.href = '/sdvs'
            }
        })
    }

    function editorDevice(id) {

        $("#checkSdvId").val(id);

        layer.open({
            type: 2,
            title: '修改维修记录',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: '/sdvmodal',
        });
    }

    /*$('.create_node').on('click', function () {
        layer.open({
            type: 2,
            title: '',
//            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area:  ['900px', '700px'],
            content: '/nodemodal',
        });
    });*/
    $('#indicatorContainer').radialIndicator({
        barColor: '#87CEEB',
        barWidth: 10,
        initValue: 40,
        roundCorner : true,
        percentage: true
    });

    $('#event').AmazeuiUpload({
        url : 'http://localhost/demo.json'
    });

</script>